package com.wc.AlgoOJ_train.train2_DP训练.c8.DP0504_数数3;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/18 15:23
 * @description http://43.138.190.70:8888/p/DP0504
 */
public class Main {
    static int N = 20;
    static int[] nums = new int[N];
    // f[i][j][k][m][n] 第i位，ai = j, ai+1 = k, ai+2 =m, 是否当前满足条件
    static long[][][][][] f = new long[N][10][10][10][2];
    static long l, r;
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);


    static void init() {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < 10; k++) {
                    for (int m = 0; m < 10; m++) {
                        Arrays.fill(f[i][j][k][m], -1L);
                    }
                }
            }
        }
    }

    public static void main(String[] args) {
        int t = 1;
        init();
        while (t-- > 0) {
            l = sc.nextLong();
            r = sc.nextLong();
            out.println(dp(r) - dp(l - 1));
        }
        out.flush();
    }

    static long dp(long n) {
        long m = n;
        int len = 0;
        while (m > 0) {
            nums[++len] = (int) (m % 10);
            m /= 10;
        }
        return dfs(len, -1, -1, -1, 1, 0, 1);
    }

    /**
     * @param cnt   位置
     * @param p1    ai
     * @param p2    ai + 1
     * @param p3    ai + 2
     * @param limit 是否有限制
     * @param fill  是否前面已经有满足的了
     * @param zero  是否存在前导0
     * @return 答案
     */
    static long dfs(int cnt, int p1, int p2, int p3, int limit, int fill, int zero) {
        if (p1 != -1 && p1 < p2 && p2 < p3) {
//            System.out.println(p1+" "+p2+" "+p3+"=====");
            fill = 1;
        }
        // 到达最后最后一个低位了，最后位是否满足
        if (cnt == 0) {
            return fill;
        }
        // 如果前面已经计算过了，就不需要计算了
        if (p1 != -1 && limit == 0 && f[cnt][p1][p2][p3][fill] != -1)
            return f[cnt][p1][p2][p3][fill];

        long res = 0;
        // 查看前面是否有限制，只有最后的数才有限制
        int up = limit == 1 ? nums[cnt] : 9;
        for (int i = 0; i <= up; i++) {
            // 判断前导0的做法
            if (zero == 1 && i == 0)
                res += dfs(cnt - 1, p2, p3, -1, limit & (i == up ? 1 : 0), fill, zero & (i == 0 ? 1 : 0));
                // 当不是前导0
            else res += dfs(cnt - 1, p2, p3, i, limit & (i == up ? 1 : 0), fill, zero & (i == 0 ? 1 : 0));
        }
        // 当没有限制
        if (p1 != -1 && limit == 0)
            f[cnt][p1][p2][p3][fill] = res;

        return res;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
